/* 
 * This file is part of Soft Mood (https://notabug.org/alkeon/soft-mood).
 * Copyright (c) 2019 Alejandro "alkeon" Castilla
 * 
 * This program is free software: you can redistribute it and/or modify  
 * it under the terms of the GNU General Public License as published by  
 * the Free Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License 
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef __SDL_SLIDER__
#define __SDL_SLIDER__
#include <iostream>
#include "SDL_mixer.h"
#include "SDL_image.h"
#include "SDL.h"
#include <thread>
#include <chrono>
using namespace std;

#define SLIDER_WIDTH 32
#define SLIDER_HEIGHT 46

class slider{
	
	string _image_file;
	bool _has_image;
	SDL_Renderer * _src;
	SDL_Rect _fillbar_dst;
	SDL_Rect _button_dst;
	SDL_Rect _button_bounds_dst;
	bool _mouse_follow	= false;
	int _value;
	int _pos_x;
	int _pos_y;
	
	public:

		slider(SDL_Renderer * src, int pos_x, int pos_y);

		void set_image(const string& file);
		void test_mouse_follow(SDL_Point* mouse, SDL_Point* mouse_offset);
		void mouse_follow_off(){ _mouse_follow = false; }

		SDL_Rect get_button_dst() { return _button_dst; }		
		int get_value() { return _value; }

		void draw_image();
		void draw();

		void update(int pos_y);
		
};
#endif
